//
//  MainViewController.swift
//  SecretChat
//
//  Created by TimTiger on 16/6/21.
//  Copyright © 2016年 TimTiger. All rights reserved.
//

import UIKit
import MudFramework

/// 主页面
class MainViewController: UITabBarController {

    /** 账号信息 */
    private var accountProfileViewController: AccountProfileViewController!
    /** 聊天消息 */
    private var messageViewController: MessageViewController!
    /** 联系人 */
    private var contactsViewController: ContactsViewController!
    
    //MARK: - Life cycle
    override func viewDidLoad() {
        super.viewDidLoad()
        self.initTabControllers()
    }

    private func initTabControllers() {
        self.messageViewController = MessageViewController()
        self.messageViewController.title = MudLocalString.stringForKey("Message")
        self.messageViewController.tabBarItem.image = UIImage(named: "sc_talk_normal.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        self.messageViewController.tabBarItem.selectedImage = UIImage(named: "sc_talk_highlight.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        self.messageViewController.tabBarItem.imageInsets = UIEdgeInsetsMake(-2, 0, 2, 0)
        self.messageViewController.tabBarItem.tag = 201
        let messageNavigationController: MudNavigationController = MudNavigationController(rootViewController: self.messageViewController)
        
        self.contactsViewController = ContactsViewController()
        self.contactsViewController.title = MudLocalString.stringForKey("Contacts")
        self.contactsViewController.tabBarItem.image = UIImage(named: "sc_contacts_normal.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        self.contactsViewController.tabBarItem.selectedImage = UIImage(named: "sc_contacts_highlight.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        self.contactsViewController.tabBarItem.imageInsets = UIEdgeInsetsMake(-2, 0, 2, 0)
        self.contactsViewController.tabBarItem.tag = 202
        let contactsNavigationController: MudNavigationController = MudNavigationController(rootViewController: self.contactsViewController)
        
        self.accountProfileViewController = AccountProfileViewController()
        self.accountProfileViewController.title = MudLocalString.stringForKey("Profile")
        self.accountProfileViewController.tabBarItem.image = UIImage(named: "sc_profile_normal.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        self.accountProfileViewController.tabBarItem.selectedImage = UIImage(named: "sc_profile_highlight.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        self.accountProfileViewController.tabBarItem.imageInsets = UIEdgeInsetsMake(-2, 0, 2, 0)
        self.accountProfileViewController.tabBarItem.tag = 203
        let profileNavigationController: MudNavigationController = MudNavigationController(rootViewController: self.accountProfileViewController)
        
        self.tabBar.tintColor = UIColor.whiteColor()
        self.tabBar.itemSpacing = 0.5
        self.setViewControllers([messageNavigationController,contactsNavigationController,profileNavigationController], animated: true)
    }
    
}
